import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

//标题文本15号
TextStyle titleTextStyle15 = TextStyle(color: Colors.black, fontSize: 15.sp);

//普通字体，只做判空处理
Text normalText(String? text) {
  return Text(
    text ?? "",
    style: titleTextStyle15,
  );
}

//通用的输入框
Widget commonInput(
    {String? labelText,
    TextEditingController? controller,
    ValueChanged<String>? onChanged,
    bool? obscureText}) {
  return TextField(
    obscureText: obscureText ?? false,
    controller: controller,
    onChanged: onChanged,
    style: TextStyle(color: Colors.white, fontSize: 14.sp),
    cursorColor: Colors.white,
    decoration: InputDecoration(
        //为获取焦点前边框样式
        enabledBorder: OutlineInputBorder(
            borderSide: BorderSide(color: Colors.white, width: 0.5.r)),
        focusedBorder: OutlineInputBorder(
            borderSide: BorderSide(color: Colors.white, width: 1.r)),
        labelText: labelText ?? "请输入",
        labelStyle: TextStyle(color: Colors.white)),
  );
}

//白色边框圆角按钮
Widget whiteBorderButton({required String title, GestureTapCallback? onTap}) {
  return GestureDetector(
    onTap: onTap,
    child: Container(
      alignment: Alignment.center,
      width: double.infinity,
      height: 45.h,
      margin: EdgeInsets.only(left: 40.w, right: 40.w),
      decoration: BoxDecoration(
          borderRadius: BorderRadius.all(Radius.circular(22.5.r)),
          border: Border.all(color: Colors.white, width: 1.r)),
      child: Text(
        title,
        style: TextStyle(color: Colors.white, fontSize: 15.sp),
      ),
    ),
  );
}

//收藏按钮
Widget collectImage(bool? collect, {GestureTapCallback? onTap}) {
  return GestureDetector(
      onTap: onTap,
      child: Image.asset(
          collect == true
              ? "assets/images/img_collect"
              ".png"
              : "assets/images/img_collect_grey.png",
          width: 25.r,
          height: 25.r));
}
